<template>
	<view class="u-flex-col u-col-center">
		<view class="u-flex page-font">
			<text>*当前为EC首产，请拍照上传</text>
		</view>
		<view class="toTop">
			<u-upload
			@on-success="sucess"
			@on-remove="remove" 
			:max-count="1" 
			:width="500" 
			:height ="400" 
			ref="uUpload" 
			:action="action" 
			:auto-upload="true" ></u-upload>
		</view>
		<u-button @click="submit" class="sureBtn">确定</u-button>
		<u-top-tips ref="uTips"></u-top-tips>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				action: 'https://www.golwayhhln.top/hnsMes/fileTransmit/detectionFile',
				ecnImgUrl: ''
			}
		},
		// 进入home页面即获取该用户信息
		onLoad() {

		},
		methods: {
			sucess(e){
				console.log('拍照上传',e)
				this.ecnImgUrl = e.data.results
				this.$refs.uTips.show({
					title: '上传成功！',
					type: 'success',
					duration: '2000'
				})
			},
			remove(index){
				console.log(index)
				this.ecnImgUrl = ''
			},
			submit(){
				if(!this.ecnImgUrl) return this.$refs.uTips.show({
					title: '请上传图片！',
					type: 'warning',
					duration: '2000'	
				})
				uni.setStorageSync('ecnImgUrl',this.ecnImgUrl)
				uni.navigateBack({
					delta: 1,
					animationType: 'pop-out',
					animationDuration: 200
				});
			},
		}
	}
</script>

<style lang="scss" scoped>
.page-font {
	font-size: 30rpx;
	margin-top: 20rpx
}
.page-font text{
	text-align: center;
}
.sureBtn{
	margin-top: 20rpx;
	width: 90%;
}
.toTop{
	margin-top: 20rpx;
}
</style>
